import Vue from "vue";
import Router from "vue-router";
import Login from "./views/Login.vue";
import Home from "./views/Home.vue";
import ShopList from "./views/ShopList.vue";
import DangerShopList from "./views/DangerShopList.vue";
import UserManagementList from "./views/UserManagementList.vue";

Vue.use(Router);
var router = new Router({
  routes: [
    {
      path: "/login",
      name: "login",
      component: Login
    },
    {
      path: "/",
      redirect: "/login"
    },
    {
      path: "/home",
      name: "Home",
      component: Home,
      redirect: "/shopList",
      children: [
        {
          path: "/shopList",
          name: "ShopList",
          component: ShopList,
          meta: {
            pageTitle: "店铺基本信息"
          }
        },
        {
          path: "/dangershopList",
          name: "DangerShopList",
          component: DangerShopList,
          meta: {
            pageTitle: "隐患店招信息"
          }
        },
        {
          path: "/userList",
          name: "UserManagementList",
          component: UserManagementList,
          meta: {
            pageTitle: "用户信息"
          }
        }
      ]
    }
  ]
});
// 路由守卫设置
// router.beforeEach(function(to, from, next) {
//   var token = window.sessionStorage.getItem("token");
//   if (token === null && to.path !== "/login") {
//     // if (
//     //   to.path.includes("/apply") ||
//     //   to.path.includes("/verification") ||
//     //   to.path.includes("/smsVerification") ||
//     //   to.path.includes("/modify") ||
//     //   to.path.includes("/complete")
//     // ) {
//     //   next();
//     // } else {
//     //   return next("/login");
//     // }
//     return next("/login");
//   }
//   next(); // 放行
// });
export default router;
